home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -seriously_amiga- / shareware / programming / other / gui4cli / dir / dir.g < prev    next >
Text File  |  1997-11-17  |  9KB  |  394 lines

  1. G4C  
  2.  
  3. ; This file contains the 3 pop-up on Right-Mouse-Button click GUIs.
  4.  
  5.  
  6. ;#########################################################################
  7.  
  8. ; This is the RMB pop-up gui (i.e. pops up on clicking the Right Mouse Button)
  9.  
  10. WinBig 0 0 80 105 ""
  11. WinType 00001000
  12. winonmouse 30 22 
  13. varpath dir.gc
  14.  
  15. xOnRMB 
  16. guiclose Dir.g
  17.  
  18. xOnInactive
  19. guiclose Dir.g
  20.  
  21. xOnOpen                ; upon opening the window
  22. id = $$lv.id            ; get the listview's id
  23. if $id < 1
  24.    id = 1
  25. endif
  26. if $id = 2            ; set the copy/move gadgets pointing
  27.    setgad Dir.g 1 HIDE            ; correctly according to the LV's id.
  28.    setgad Dir.g 2 HIDE
  29.    setgad Dir.g 11 show
  30.    setgad Dir.g 22 show
  31.    destid  = 1              ; store destination lv id
  32. else
  33.    setgad Dir.g 11 HIDE
  34.    setgad Dir.g 22 HIDE
  35.    setgad Dir.g 1 show
  36.    setgad Dir.g 2 show
  37.    destid = 2
  38. endif
  39. redraw Dir.g
  40. lvuse dir.gc $destid        ; use the destination lv
  41. destdir = $$lv.dir        ; store the destination dir
  42. lvuse dir.gc $id        ; restore the source lv
  43.  
  44. ;=============================== Next GUI button
  45.  
  46. xbutton 0 0 0 15 More..
  47. guiopen Dir.g3            ; open an other gui with more options
  48. guiclose Dir.g
  49.  
  50. ;=============================== copy button
  51.  
  52. xbutton 0 15 0 15 Copy->
  53. gadhelp 'Copy files from LEFT to RIGHT listview'
  54. gadid 1
  55. gosub Dir.g copy
  56.  
  57. xbutton 0 15 0 15 <-Copy
  58. gadhelp 'Copy files from RIGHT to LEFT listview'
  59. gadid 11
  60. gosub Dir.g copy
  61.  
  62. xroutine copy
  63. guiclose Dir.g
  64. lvaction copy $destdir                  ; copy all selected files/dirs
  65. lvuse dir.gc $destid
  66. lvdir refresh                   ; refresh destination
  67.  
  68. ;============================= copy new files (same logic as copy)
  69.  
  70. xbutton 0 30 0 15 "Copy New"
  71. gadhelp 'Only copy newer files'
  72. guiclose Dir.g
  73. lvaction copynew $destdir        ; same as copy, above
  74. lvuse dir.gc $destid
  75. lvdir refresh
  76.  
  77. ;=============================== Move (same logic as copy)
  78.  
  79. xbutton 0 45 0 15 Move->
  80. gadhelp 'Move selected files'
  81. gadid 2
  82. gosub Dir.g move
  83.  
  84. xbutton 0 45 0 15 <-Move
  85. gadhelp 'Move selected files'
  86. gadid 22
  87. gosub Dir.g move
  88.  
  89. xroutine move
  90. guiclose Dir.g
  91. lvaction move $destdir
  92. lvuse dir.gc $destid
  93. lvdir refresh
  94.  
  95.  
  96. ;============================== delete
  97.  
  98. xbutton 0 60 0 15 Delete
  99. gadhelp 'Delete selected Files/Directories'
  100. guiclose Dir.g
  101. lvaction delete REQ
  102.  
  103.  
  104. ;============================= rename
  105. ; This routine reads the dir listview in the normal first/next method
  106. ; using the lvmulti command and passes the files to guis:tools/rtn/GetString
  107. ; GetString calls the routine "ren" for every file..
  108.  
  109. xbutton 0 75 0 15 Rename
  110. gadhelp 'Rename selected files'
  111. guiclose Dir.g
  112. lvuse dir.gc $id
  113. lvmulti first              ; get the first record
  114. renfile = $dir.gc/lv_file  ; store name to be safe
  115. if $renfile > ' '
  116.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  117. endif
  118.  
  119. xRoutine ren newname
  120. rename $renfile $newname
  121. lvuse dir.gc $id
  122. lvmulti off
  123. extract newname file newname
  124. lvput $newname
  125. lvmulti next               ; get the next record
  126. renfile = $dir.gc/lv_file  
  127. if $renfile > ' '
  128.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  129. else
  130.    lvdir refresh
  131.    guiquit GetString
  132. endif
  133.  
  134.  
  135. ;============================== makedir
  136.  
  137. xbutton 0 90 0 15 MakeDir
  138. gadhelp 'Create a Directory'
  139. tempdir = $$lv.dir
  140. if $tempdir[-1][1] = ":"     ; add the / if not a device
  141. or $tempdir[-2][2] = ':\"'   ; taking care of quotes
  142.    ;
  143. elseif $tempdir[-1][1] = '\"'
  144.    tempdir[-1][1] = '/'
  145.    appvar tempdir '\"'
  146. else
  147.    appvar tempdir '/'
  148. endif
  149. guiload guis:tools/rtn/GetString "Create Directory:" "$dir.g/tempdir" dir.g mkdir
  150.  
  151. xroutine mkdir     ; called by getstring as above
  152. makedir $$arg.0
  153. lvdir refresh      ; hoping it's still the same listview..
  154.  
  155.  
  156. ;#########################################################################
  157.  
  158. NEWFILE dir.g3    ; The more.. gui (from the RMB pop-up gui)
  159.  
  160.  
  161. WinBig 0 0 160 105 ""
  162. WinType 00001000
  163. winonmouse 50 8 
  164. varpath dir.gc/cli.gc/fsearch.gc
  165.  
  166. xOnRMB 
  167. guiclose Dir.g3
  168.  
  169. xOnInactive
  170. guiclose Dir.g3
  171.  
  172. xOnOpen
  173. id = $$LV.ID           ; Get the id of the current lvdir
  174.  
  175. xOnClose
  176. setwintitle dir.g3 ""     ; because ezreq will change the wintitle..
  177.  
  178.  
  179. ;================================ buttons (left bank)
  180.  
  181. xbutton 0 0 40 15  <<        ; previous
  182. guiopen dir.g
  183. guiclose dir.g3
  184.  
  185. xbutton 40 0 40 15  >>        ; next
  186. guiopen dir.g4
  187. guiclose dir.g3
  188.  
  189. xbutton 0 15 80 15 View
  190. gadhelp 'View selected files according to their type'
  191. guiclose dir.g3
  192. lvuse dir.gc $id
  193. lvmulti first
  194. while $lv_file > ""
  195.     guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  196.     filetype = $$ret.0
  197.     if $filetype != NONE
  198.        guiload guis:tools/rtn/ViewFile $dir.gc/lv_file $dir.g3/filetype CLI
  199.     endif
  200.     lvmulti next
  201. endwhile
  202.  
  203. xbutton 0 30 80 15 Protect
  204. gadhelp 'Protect selected files'
  205. guiclose dir.g3
  206. guiload  :dir.prot
  207. guiopen  dir.prot
  208.  
  209. xbutton 0 45 80 15 Size
  210. gadhelp 'Show & sum size of selected items'
  211. guiclose dir.g3
  212. lvuse dir.gc $id
  213. lvaction SIZE lv_size
  214. SetWinTitle dir.gc '$lv_size bytes of $$lv.dir                           '
  215.  
  216. xbutton 0 60 80 15 Assign
  217. gadhelp 'Assign Current directory'
  218. tempdir = $$lv.dir
  219. guiclose dir.g3
  220. guiload guis:tools/rtn/GetString "Assign $dir.g3/tempdir as:" "" dir.g3 asn
  221.  
  222. xroutine asn        ; called by getstring as above
  223. assign $$arg.0 $tempdir
  224.  
  225. xbutton 0 75 80 15 'CliGui'
  226. gadhelp 'Open Guis:tools/cli.gc'
  227. cd $$lv.dir
  228. guiclose dir.g3
  229. guiload guis:tools/cli.gc  "" CLI  ; will open itself
  230.  
  231. xbutton 0 90 80 15 Shell
  232. gadhelp 'Open a new Shell'
  233. guiclose dir.g3
  234. cd $$LV.DIR
  235. run 'newshell "con:0/150/680/120/Gui4Cli/auto/close"'
  236.  
  237.  
  238. ; ------------------ Buttons right bank
  239.  
  240. xbutton 80  0 80 15 User..
  241. gadhelp 'Open the Dir/Dir.user pop-up gui'
  242. guiload :dir.user
  243. guiclose dir.g3
  244.  
  245. xbutton 80 15 80 15 Search
  246. gadhelp 'Search for files and/or text in current dir'
  247. guiclose dir.g3
  248. ; store it here, because gui has lv and will loose it..
  249. spath = $$lv.dir
  250. guiload guis:g4c/fsearch/fsearch.gc $dir.g3/spath
  251.  
  252. xbutton 80 30 80 15 Replace
  253. gadhelp 'Replace text in selected files'
  254. guiclose dir.g3
  255. guiload  :dir.rep
  256. guiopen  dir.rep
  257.  
  258. xbutton 80 45 80 15 ReWrap
  259. gadhelp 'Re-Wrap selected files'
  260. guiclose dir.g3
  261. guiload :dir.wrap
  262.  
  263. xbutton 80 60 80 15 "AddIcon"
  264. gadhelp 'Add icons (if icon for file type exists in guis:tools/icons/def)'
  265. guiclose dir.g3
  266. lvuse dir.gc $id
  267. lvmulti first
  268. while $lv_file > ''
  269.    if $lv_file[-1][1] = '\"'  ; care for possible quotes
  270.       fname = $lv_file
  271.       fname[-1][1] = '.'
  272.       fname = '$fname\info\"'
  273.    else
  274.       fname = $lv_file\.info
  275.    endif
  276.    if $$lv.type == DIR
  277.       copy guis:tools/icons/def/DRAWER.info $fname
  278.    else
  279.       guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  280.       filetype = $$ret.0
  281.       infoname = "guis:tools/icons/def/$filetype\.info"
  282.       ifexists file $infoname
  283.          copy $infoname $fname
  284.       endif
  285.    endif
  286.    lvmulti off
  287.    lvmulti next
  288. endwhile
  289. lvdir refresh
  290.  
  291. xbutton 80 75 80 15 ""
  292.  
  293. xbutton 80 90 80 15 ""
  294.  
  295.  
  296.  
  297. ;#########################################################################
  298.  
  299. NEWFILE dir.g4    ; The more->more.. gui (from the RMB pop-up gui)
  300.                   ; Define your own functions here...
  301.  
  302. WinBig 0 0 160 105 ""
  303. WinType 00001000
  304. winonwin Dir.g3 0 0 
  305. varpath dir.gc
  306.  
  307. xOnRMB 
  308. guiclose Dir.g4
  309.  
  310. xOnInactive
  311. guiclose Dir.g4
  312.  
  313.  
  314. ;================================ buttons (left bank)
  315.  
  316. xbutton 0 0 80 15  <<
  317. guiopen dir.g3
  318. guiclose dir.g4
  319.  
  320. xbutton 0 15 80 15 Calc
  321. gadhelp 'Load Guis:tools/calc.gc'
  322. guiclose dir.g4
  323. guiload guis:tools/calc.gc
  324.  
  325. xbutton 0 30 80 15 Lock
  326. gadhelp 'Load Guis:tools/lock.gc'
  327. guiclose dir.g4
  328. guiload :dir.lock
  329.  
  330. xbutton 0 45 80 15 PPShow
  331. gadhelp 'Open Gui for the PPShow graphics player'
  332. guiclose dir.g4
  333. guiload :dir.ppshow
  334.  
  335. xbutton 0 60 80 15 'Palette'
  336. gadhelp 'Opens the Palette gui'
  337. guiclose dir.g3
  338. guiload  guis:tools/palette.gc
  339.  
  340. xbutton 0 75 80 15 GfxCon
  341. gadhelp 'Opens gui for GfxCon picture converter'
  342. guiclose dir.g4
  343. guiload :dir.gfxcon
  344.  
  345. xbutton 0 90 80 15 Avail
  346. gadhelp 'Opens Gui for showing memory usage'
  347. guiclose dir.g4
  348. guiload :dir.avail
  349.  
  350. ; ------------------ Buttons right bank
  351.  
  352. xbutton 80  0 80 15 'LHa Pack'
  353. gadhelp 'Pack Selected files' 
  354. guiclose dir.g4
  355. guiload :dir.lha
  356.  
  357. xbutton 80 15 80 15 'XPK'
  358. gadhelp 'Load gui for XPK packers'
  359. guiclose dir.g4
  360. guiload :dir.xpack
  361.  
  362. xbutton 80 30 80 15 ""
  363.  
  364. xbutton 80 45 80 15 "GuiEdit"    ; start up a gui editor kind of thing..
  365. gadhelp "Open gui with gadgets for copying (it'll get better..)"
  366. guiclose dir.g4
  367. guiload guis:tools/guiedit.gc
  368. guiopen guiedit.gc
  369.  
  370. xbutton 80 60 80 15 Config
  371. gadhelp 'Loads the configuration gui'
  372. guiclose dir.g4
  373. guiload guis:tools/config.gc
  374.  
  375. xbutton 80 75 80 15 Help
  376. gadhelp 'Loads the dir.gc guide'
  377. extract dir.gc guipath lv_path
  378. joinfile $lv_path dir.guide lv_guide
  379. run '$*DEF.GUIDE $lv_guide'
  380. delvar lv_path
  381. delvar lv_guide
  382.  
  383. xbutton 80 90 80 15 Quit
  384. guiclose dir.g4
  385. ezreq "QUIT ???!!..\nWho, me ?\n" 'DIE!|Well..' lv_ask
  386. if $lv_ask = 1
  387.    guiquit dir.gc
  388. endif
  389.  
  390. ; the pop-up on double-click guis have been moved to file guis:dir/dir.g2
  391.  
  392.  
  393.  
  394.